﻿// TODO: Needs to be fixed for new ImageData setup.


//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Text.RegularExpressions;

//namespace TLD_Vision.OCR
//{
//    public class ShapeContextMatcher
//    {
//                private String testsetPath;

//                public ShapeContextMatcher(String testsetPath)
//        {
//            this.testsetPath = testsetPath;
//        }

//        public void RunTestset(Image src, List<OCRResult> resultList) 
//        {
//            if (src == null) {
//                return;
//            }

//            ShapeContexts sc = new ShapeContexts(50, 5, 12, src);

//            Regex extensionRegex = new Regex(@"\.(jpe?g|png|bmp)$");
//            Regex filenameRegex = new Regex(@"(.+)_(.)$");
            
//            if (System.IO.Directory.Exists(testsetPath))
//            {
//                foreach (String filename in System.IO.Directory.EnumerateFiles(testsetPath))
//                {
//                    if (extensionRegex.IsMatch(filename))
//                    {
//                        String fontName = System.IO.Path.GetFileNameWithoutExtension(filename);
//                        String ch = " ";
//                        Match match = filenameRegex.Match(fontName);

//                        if (match.Success) {
//                            fontName = match.Groups[1].Value;
//                            ch = match.Groups[2].Value;
//                        }
                        

//                        Image rhs = new TLD_Vision.Image(filename);
//                        rhs = rhs.Crop(rhs.FindCharacterRectangle()).Resize(50,50);

//                        double sum = sc.GetCost(rhs);
//                        resultList.Add(new OCRResult(fontName, ch, sum));
//                    }
//                }
//            }
//        }
//    }
//}
